package com.ruanxie.controller.ai;

import com.google.auto.service.AutoService;
import com.ruanxie.result.Result;
import com.ruanxie.service.AiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/ai")
@Slf4j
@Api(tags = "智能问答端")
public class AiController {

    @Autowired
    private AiService aiService;


    @PostMapping("/chat")
    @ApiOperation("ai智能问答")
    public Result<String> ai(@RequestBody String question) {
        System.setProperty("org.slf4j.simpleLogger.logFile", "System.out");
//        System.out.println(aiService.testSseInvoke(question));
        String result=aiService.testSseInvoke(question);
        log.info("问题：{}/n答案：{}",question,result);
        return Result.success(result);
    }
}
